class InitialSetup < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.column  :username, :string, :null => false
      t.column  :name, :string
      #This column contains an MD5 hash of the password
      t.column  :password, :string, :limit => 32, :null => false
      t.column  :email, :string
    end
    create_table :images do |t|
      t.column  :name, :string,  :null => false
      t.column  :filename, :string
      t.column  :user_id, :integer,  :null => false
    end
    create_table :tags do |t|
      t.column  :name, :string,  :null => false
      t.column  :user_id, :integer,  :null => false
    end
    create_table :images_tags, :id => false do |t|
      t.column  :image_id, :string, :null => false
      t.column  :tag_id, :string, :null => false
    end
    add_index :images_tags, [:image_id, :tag_id], :unique
  end

  def self.down
    drop_table  :users
    drop_table  :images
    drop_table  :tags
    drop_table  :images_tags
  end
end
